<script>
    $(function() {
        combo("<?php echo base_url("intranet/administrador/combo/tipoEmpleado") ?>", "tipoPersonal");

        $('#formProd').validate({
            errorElement: 'span',
            errorClass: 'help-inline',
            focusInvalid: false,
            rules: {
                desc: {
                    required: true,
                    minlength: 3,
                },
                precio: {
                    required: true,
                    number: true
                }
            },
            messages: {
                desc: {
                    required: "Debe ingresar una descripción",
                    minlength: "La descripción debe tener un minimo de 3 caracteres"
                },
                precio: {
                    required: "Debe ingresar un precio",
                    number: "Debe ingresar una cantidad numérica"
                }
            },
            highlight: function(e) {
                $(e).closest('.control-group').removeClass('info').addClass('error');
            },
            success: function(e) {
                $(e).closest('.control-group').removeClass('error').addClass('info');
                $(e).remove();
            }/*,
            submitHandler: function(form) {
            },
            invalidHandler: function(form) {
            }*/
        });
    });
</script>
<div class="page-content">
    <div class="page-header position-relative">
        <h1>Producto<small><i class="icon-double-angle-right"></i> Mantenimiento</small></h1>
    </div>
    <div class="row-fluid">
        <div class="span12">
            <div class="widget-box">
                <div class="widget-header"><h4>Formulario Producto</h4>
                    <span class="widget-toolbar">
                        <a data-action="collapse" href="#">
                            <i class="icon-chevron-up"></i>
                        </a>
                    </span>
                </div>

                <?php
                if (empty($registros)) {
                    $codigo = "";
                    $descripcion = "";
                    $precio = "";
                } else {
                    $codigo = $registros[0]->cod_prod;
                    $descripcion = $registros[0]->desc_prod;
                    $precio = $registros[0]->pre_prod;
                }
                ?>
                <div class="widget-body">
                    <div class="widget-body-inner">
                        <div class="widget-main">


                            <form id="formProd" action="<?php echo base_url("intranet/administrador/registrarModificarProducto"); ?>" class="form-horizontal" method='post'>

                                <div class="row-fluid">
                                    <div class="span7">
                                        <div class="control-group">
                                            <label class="control-label" for="nom">Producto</label>
                                            <div class="controls">
                                                <input type='hidden' id='cod' name='cod' value="<?php echo $codigo; ?>">
                                                <input type='text' id='desc' class="required" name='desc' value="<?php echo $descripcion; ?>" >
                                            </div>                                            
                                        </div>
                                        <div class="control-group">
                                            <label class="control-label" for="ape">Precio</label>
                                            <div class="controls">
                                                <input type='text' id='precio' name='precio' class="span3 required" value="<?php echo $precio; ?>">
                                            </div>                                            
                                        </div>
                                    </div>
                                </div>
                                <div class="form-actions">
                                    <button type='submit' class='btn btn-primary'><i class="icon-save"></i> Guardar</button>                    
                                </div>

                            </form>


                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
